// ----------------------------------------------------------------------------
// thread.cpp 
// ----------------------------------------------------------------------------
#include <fw/base/concurrent/thread.h>
#include <fw/base/core/macros.h>
#if   defined(FW_TARGET_WINDOWS)
#include <fw/base/concurrent/_Windows/thread_impl.windows.h>
#elif defined(FW_TARGET_APPLE)
#include <fw/base/concurrent/_MacOSX/thread_impl.apple.h>
#else
#error		"未対応のプラットフォームです."
#endif

namespace fw
{
	Thread::Thread()
	{
		m_impl = new ThreadImpl();
	}

	Thread::~Thread()
	{
		if(m_impl){ delete m_impl; m_impl=0; }
	}
	
	void Thread::Attach(const char* name, Affinity affinitymask)
	{
		
	}
	
	void Thread::Initialize	(const char*  name,
							 ThreadFunc   func,
							 ThreadArg    arg,
							 Affinity     affinitymask,
							 Priority     priority,
							 size_t       stacksize)
	{
		if(m_impl)
		{
			m_impl->Initialize(name, func, arg, affinitymask, priority, stacksize);
		}
	}
	void Thread::Join()
	{
		if(m_impl)
		{
			m_impl->Join();
		}
	}

	int	Thread::GetNumberOfProcessors()
	{
		return Impl_GetNumberOfProcessors();
	}
	
} // namespace fw 

#if defined(FW_ENABLE_UNIT_TEST)
#include <gtest/gtest.h>

TEST(Concurrent, Thread)
{
	int i=0;
	ASSERT_EQ(i,0);
}

#endif // FW_ENABLE_UNIT_TEST
